package com.zone.domain.strategy.service.armory.assemble;

import com.zone.domain.strategy.model.entity.StrategyAwardEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: zongzi
 * @description: 策略装配广播器，循环执行所有的装配处理器
 * @date: 2024/5/30
 */
@Slf4j
@Service
public class StrategyAssembleBroadcaster {
    // 装配处理器集合
    private final List<IStrategyAssembleHandler> assembleHandlerList;

    public StrategyAssembleBroadcaster(List<IStrategyAssembleHandler> assembleHandlerList) {
        this.assembleHandlerList = assembleHandlerList;
    }

    /**
     * 进行广播，各个策略处理器进行策略装配
     *
     * @param strategyId              策略id
     * @param strategyAwardEntityList 策略明细集合
     */
    public void broadcastAssemble(Long strategyId, List<StrategyAwardEntity> strategyAwardEntityList) {
        // 循环调用各个处理器进行策略装配
        assembleHandlerList.forEach(strategyRuleHandler -> strategyRuleHandler.assembleStrategy(strategyId, strategyAwardEntityList));
    }
}
